<template>
  <div v-show="props.show" class="loading-container">
    <div class="loading-wrapper">
      <div class="my-loading">
        <div class="loading">
          <span>加</span>
          <span>载</span>
          <span>中</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
const props = defineProps({
  show: {
    type: Boolean,
    default: true,
  },
});
</script>

<style lang="scss" scoped>
.loading-container {
  position: fixed;
  z-index: 999999;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(42, 122, 197, 0.7);
}
.loading-wrapper {
  height: 350rpx;
  width: 350rpx;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.my-loading {
  height: 350rpx;
  width: 350rpx;
  background: url("../../static/loading.gif");
  border-radius: 50%;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.loading-text {
  text-align: center;
  color: white;
  line-height: 350rpx;
}
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
}

.loading span {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin: 0 10px;
  border-radius: 50%;
  color: black;
  animation: loading 1.5s ease-in-out infinite;
}

.loading span:nth-child(1) {
  /* background-color: #000; */
  animation-delay: 0.1s;
  color: white;
}

.loading span:nth-child(2) {
  /* background-color: #111; */
  animation-delay: 0.2s;
  color: white;
}

.loading span:nth-child(3) {
  /* background-color: #222; */
  animation-delay: 0.3s;
  color: white;
}

@keyframes loading {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.5);
  }
  100% {
    transform: scale(1);
  }
}
</style>
